Program total_short_int
    character*64 raw
      character*6 ticker
      character*8 cusp,lcusp,cusip(1264),date
      character*12 nshrt
      integer(kind=8):: nshrs,nvalue,jvalue,ivol,numshrs
      dimension nep(1264),idate(1264),ic(5)
!      open(unit=10,file='e:\FIS\episode_results.txt')
!      open(unit=11,file='e:\FIS_duration\short_interest.csv')
!      open(unit=99,file='e:\FIS_duration\short_int_episode.txt')
      open(unit=10,file='e:\FIS\episode_results_rep.txt')
      open(unit=11,file='e:\FIS_duration\short_interest.csv')
      open(unit=99,file='e:\FIS_duration\short_int_episode_rep.txt')
      lcusp='zzzzzzzz'
      iend=0
      do 1 i=1,1264
         read(10,1000)nep(i),idate(i),cusip(i)
1000     format(1x,i4,12x,i8,1x,a8)        
1     continue   
10    read(11,1100,end=900)raw
1100  format(a64)
      nc=0
      ii=0
15    ii=ii+1
      if(raw(ii:ii).ne.',') go to 15
      nc=nc+1
      ic(nc)=ii
      if(nc.lt.5) go to 15
      ib=ic(5)+1
      ie=ic(5)+8
      n=0
      do 20 ii=ib,ie
          n=n+1
20    cusp(n:n)=raw(ii:ii)
      ib=ic(4)+1
      ie=ic(4)+8
      n=0
      do 25 ii=ib,ie
          n=n+1
25        date(n:n)=raw(ii:ii)
      ib=ic(2)+1
      ie=ic(3)-1
      id=0
      do 30 ii=ib,ie
30    if(raw(ii:ii).eq.'.') id=ii
      nshrt='            '
      ie2=ie
      if(id.ne.0) ie2=id-1
      n=13
      do 35 ii=ie2,ib,-1
          n=n-1
35        nshrt(n:n)=raw(ii:ii)
      if(cusp.eq.lcusp) go to 100
      lcusp=cusp
      inc=0
      do 60 ii=1,1264
          if(cusp.eq.cusip(ii)) inc=1
60    continue
      
100   continue 
      if(inc.eq.1) write(6,6001)cusp,date,nshrt
      if(inc.eq.1) write(99,6001)cusp,date,nshrt
6001  format(1x,a8,1x,a8,1x,a12)
      
      go to 10
900   continue
      stop
end program total_short_int